<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>xmake v2.5.9 released, Improve C++20 Modules and support Nim, Keil MDK and Unity Build</title>
    <meta name="description" content="xmake is a lightweight cross-platform build tool based on Lua. It uses xmake.lua to maintain project builds. Compared with makefile/CMakeLists.txt, the confi...">

    
    <meta name="keywords" content="xmake,lua,C/C++,Nim,Keil,MDK,circle,Unity,Build,C++20,Modules,lua5.4,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/2021/10/30/xmake-update-v2.5.9/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/cn?lang=0">
                    
                        <i class="fa fa-home"></i>中文
                    </a>
                </li>

                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>Projects
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/archive/">
                            
                        
                            <i class="fa fa-archive"></i>Archives
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/category/">
                            
                        
                            <i class="fa fa-th-list"></i>Categories
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/tag/">
                            
                        
                            <i class="fa fa-tags"></i>Tags
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/docs/">
                            
                        
                            <i class="fa fa-book"></i>Documents
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="https://xmake.io/#/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>Community
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/donation/">
                            
                        
                            <i class="fa fa-heart"></i>Donate
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/about/">
                            
                        
                            <i class="fa fa-user"></i>About
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                     
                     
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>xmake v2.5.9 released, Improve C++20 Modules and support Nim, Keil MDK and Unity Build</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2021-10-30
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a-->
        <a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a>&nbsp;
    
        <!--a href="/tag/#C%2FC%2B%2B" title="Tag: C/C++" rel="tag">C/C++</a-->
        <a href="/tag/#C/C++" title="Tag: C/C++" rel="tag">C/C++</a>&nbsp;
    
        <!--a href="/tag/#Nim" title="Tag: Nim" rel="tag">Nim</a-->
        <a href="/tag/#Nim" title="Tag: Nim" rel="tag">Nim</a>&nbsp;
    
        <!--a href="/tag/#Keil" title="Tag: Keil" rel="tag">Keil</a-->
        <a href="/tag/#Keil" title="Tag: Keil" rel="tag">Keil</a>&nbsp;
    
        <!--a href="/tag/#MDK" title="Tag: MDK" rel="tag">MDK</a-->
        <a href="/tag/#MDK" title="Tag: MDK" rel="tag">MDK</a>&nbsp;
    
        <!--a href="/tag/#circle" title="Tag: circle" rel="tag">circle</a-->
        <a href="/tag/#circle" title="Tag: circle" rel="tag">circle</a>&nbsp;
    
        <!--a href="/tag/#Unity" title="Tag: Unity" rel="tag">Unity</a-->
        <a href="/tag/#Unity" title="Tag: Unity" rel="tag">Unity</a>&nbsp;
    
        <!--a href="/tag/#Build" title="Tag: Build" rel="tag">Build</a-->
        <a href="/tag/#Build" title="Tag: Build" rel="tag">Build</a>&nbsp;
    
        <!--a href="/tag/#C%2B%2B20" title="Tag: C++20" rel="tag">C++20</a-->
        <a href="/tag/#C++20" title="Tag: C++20" rel="tag">C++20</a>&nbsp;
    
        <!--a href="/tag/#Modules" title="Tag: Modules" rel="tag">Modules</a-->
        <a href="/tag/#Modules" title="Tag: Modules" rel="tag">Modules</a>&nbsp;
    
        <!--a href="/tag/#lua5.4" title="Tag: lua5.4" rel="tag">lua5.4</a-->
        <a href="/tag/#lua5.4" title="Tag: lua5.4" rel="tag">lua5.4</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p><a href="https://github.com/xmake-io/xmake">xmake</a> is a lightweight cross-platform build tool based on Lua. It uses xmake.lua to maintain project builds. Compared with makefile/CMakeLists.txt, the configuration syntax is more Concise and intuitive, it is very friendly to novices, and you can get started quickly in a short time, allowing users to focus more on actual project development.</p>

<p>In this version, we have added a lot of heavyweight new features, such as: Nim language project build support, Keil MDK, Circle and Wasi toolchain support.</p>

<p>In addition, we have made major improvements to C++20 Modules, not only supporting the latest gcc-11, clang and msvc compilers,
but also automatic analysis of inter-module dependencies to achieve maximum parallel compilation support.</p>

<p>Finally, there is a more useful feature that is Unity Build support, through which we can greatly improve the compilation speed of C++ code.</p>

<ul>
  <li><a href="https://github.com/xmake-io/xmake">Github</a></li>
  <li><a href="https://xmake.io/">Document</a></li>
</ul>

<h2 id="new-feature-introduction">New feature introduction</h2>

<h3 id="nimlang-project-construction">Nimlang project construction</h3>

<p>Recently, we have added build support for the Nimlang project. For related issues, see: <a href="https://github.com/xmake-io/xmake/issues/1756">#1756</a></p>

<h4 id="create-an-empty-project">Create an empty project</h4>

<p>We can use the <code class="highlighter-rouge">xmake create</code> command to create an empty project.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code>xmake create -l nim -t console test
xmake create -l nim -t static test
xmake create -l nim -t shared test
</code></pre>
</div>

<h4 id="console-program">Console Program</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/main.nim"</span><span class="p">)</span>
</code></pre>
</div>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> -v
</span>[33%]: linking.release test
/usr/local/bin/nim c --opt:speed --nimcache:build/.gens/test/macosx/x86_64/release/nimcache -o:b
uild/macosx/x86_64/release/test src/main.nim
[100%]: build ok!
</code></pre>
</div>

<h4 id="static-library-program">Static library program</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"static"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/foo.nim"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_deps</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/main.nim"</span><span class="p">)</span>
</code></pre>
</div>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> -v
</span>[33%]: linking.release libfoo.a
/usr/local/bin/nim c --opt:speed --nimcache:build/.gens/foo/macosx/x86_64/release/nimcache --app
:staticlib --noMain --passC:-DNimMain=NimMain_B6D5BD02 --passC:-DNimMainInner=NimMainInner_B6D5B
D02 --passC:-DNimMainModule=NimMainModule_B6D5BD02 --passC:-DPreMain=PreMain_B6D5BD02 --passC:-D
PreMainInner=PreMainInner_B6D5BD02 -o:build/macosx/x86_64/release/libfoo.a src/foo.nim
[66%]: linking.release test
/usr/local/bin/nim c --opt:speed --nimcache:build/.gens/test/macosx/x86_64/release/nimcache --pa
ssL:-Lbuild/macosx/x86_64/release --passL:-lfoo -o:build/macosx/x86_64/release/test src/main.nim
[100%]: build ok!
</code></pre>
</div>

<h4 id="dynamic-library-program">Dynamic library program</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"shared"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/foo.nim"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_deps</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/main.nim"</span><span class="p">)</span>
</code></pre>
</div>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> -rv
</span>[33%]: linking.release libfoo.dylib
/usr/local/bin/nim c --opt:speed --nimcache:build/.gens/foo/macosx/x86_64/release/nimcache --app
:lib --noMain -o:build/macosx/x86_64/release/libfoo.dylib src/foo.nim
[66%]: linking.release test
/usr/local/bin/nim c --opt:speed --nimcache:build/.gens/test/macosx/x86_64/release/nimcache --pa
ssL:-Lbuild/macosx/x86_64/release --passL:-lfoo -o:build/macosx/x86_64/release/test src/main.nim
[100%]: build ok!
</code></pre>
</div>

<h4 id="c-code-mixed-compilation">C code mixed compilation</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"static"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_deps</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/main.nim"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="nimble-dependency-package-integration">Nimble dependency package integration</h4>

<p>For a complete example, see: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/nim/nimble_package">Nimble Package Example</a></p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">add_requires</span><span class="p">(</span><span class="s2">"nimble::zip &gt;0.3"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/main.nim"</span><span class="p">)</span>
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"nimble::zip"</span><span class="p">)</span>
</code></pre>
</div>

<p>main.nim</p>

<div class="language-nim highlighter-rouge"><pre class="highlight"><code><span class="k">import</span> <span class="n">zip</span><span class="o">/</span><span class="n">zlib</span>

<span class="n">echo</span> <span class="n">zlibVersion</span><span class="p">()</span>
</code></pre>
</div>

<h4 id="native-dependency-package-integration">Native dependency package integration</h4>

<p>For a complete example, see: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects/nim/native_package">Native Package Example</a></p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/main.nim"</span><span class="p">)</span>
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">)</span>
</code></pre>
</div>

<p>main.nim</p>

<div class="language-nim highlighter-rouge"><pre class="highlight"><code><span class="k">proc </span><span class="nf">zlibVersion</span><span class="p">():</span> <span class="n">cstring</span> <span class="p">{.</span><span class="n">cdecl</span><span class="p">,</span> <span class="n">importc</span><span class="p">}</span>

<span class="n">echo</span> <span class="n">zlibVersion</span><span class="p">()</span>
</code></pre>
</div>

<h3 id="unity-build-acceleration">Unity Build acceleration</h3>

<p>We know that C++ code compilation speed is usually very slow, because each code file needs to parse the imported header file.</p>

<p>With Unity Build, we accelerate the compilation of the project by combining multiple cpp files into one. The main benefit is to reduce the repetitive work of parsing and compiling the contents of the header files contained in multiple source files. The contents of the header files are usually It accounts for most of the code in the source file after preprocessing.</p>

<p>Unity build also reduces the overhead caused by having a large number of small source files by reducing the number of object files created and processed by the compilation chain, and allows inter-procedural analysis and optimization across files that form a unified build task (similar to optimization during effect linking ).</p>

<p>It can greatly improve the compilation speed of C/C++ code, usually by 30%. However, depending on the complexity of the project, the benefits it brings depend on the situation of the project.</p>

<p>xmake has also supported this build mode in v2.5.9. For related issues, see <a href="https://github.com/xmake-io/xmake/issues/1019">#1019</a>.</p>

<h4 id="how-to-enable">How to enable?</h4>

<p>We provide two built-in rules to handle Unity Build for C and C++ code respectively.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"c.unity_build"</span><span class="p">)</span>
<span class="n">add_rules</span><span class="p">(</span><span class="s2">"c++.unity_build"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="batch-mode">Batch mode</h4>

<p>By default, as long as the above rules are set, Unity Build in Batch mode will be enabled, that is, xmake will automatically organize and merge according to the project code files.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_includedirs</span><span class="p">(</span><span class="s2">"src"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"c++.unity_build"</span><span class="p">,</span> <span class="p">{</span><span class="n">batchsize</span> <span class="o">=</span> <span class="mi">2</span><span class="p">})</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">,</span> <span class="s2">"src/*.cpp"</span><span class="p">)</span>
</code></pre>
</div>

<p>We can additionally specify the size of each merged Batch by setting the <code class="highlighter-rouge"><span class="p">{</span><span class="err">batchsize</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">2</span><span class="p">}</span></code> parameter to the rule, which means that every two C++ files are automatically merged and compiled.</p>

<p>The compilation effect is roughly as follows:</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> -r
</span>[11%]: ccache compiling.release build/.gens/test/unity_build/unity_642A245F.cpp
[11%]: ccache compiling.release build/.gens/test/unity_build/unity_bar.cpp
[11%]: ccache compiling.release build/.gens/test/unity_build/unity_73161A20.cpp
[11%]: ccache compiling.release build/.gens/test/unity_build/unity_F905F036.cpp
[11%]: ccache compiling.release build/.gens/test/unity_build/unity_foo.cpp
[11%]: ccache compiling.release build/.gens/test/unity_build/main.c
[77%]: linking.release test
[100%]: build ok
</code></pre>
</div>

<p>Since we only enabled the Unity Build of C++, the C code is still compiled one by one normally. In addition, in the Unity Build mode, we can still speed up the parallel compilation as much as possible without conflicting each other.</p>

<p>If the <code class="highlighter-rouge">batchsize</code> parameter is not set, all files will be merged into one file for compilation by default.</p>

<h4 id="group-mode">Group Mode</h4>

<p>If the automatic merging effect of the above Batch mode is not satisfactory, we can also use custom grouping to manually configure which files are merged together to participate in the compilation, which makes users more flexible and controllable.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"c++.unity_build"</span><span class="p">,</span> <span class="p">{</span><span class="n">batchsize</span> <span class="o">=</span> <span class="mi">0</span><span class="p">})</span> <span class="o">-</span> <span class="n">disable</span> <span class="n">batch</span> <span class="n">mode</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">,</span> <span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/foo/*.c"</span><span class="p">,</span> <span class="p">{</span><span class="n">unity_group</span> <span class="o">=</span> <span class="s2">"foo"</span><span class="p">})</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/bar/*.c"</span><span class="p">,</span> <span class="p">{</span><span class="n">unity_group</span> <span class="o">=</span> <span class="s2">"bar"</span><span class="p">})</span>
</code></pre>
</div>

<p>We use <code class="highlighter-rouge"><span class="p">{</span><span class="err">unity_group</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="nt">"foo"</span><span class="err">}</span></code> to specify the name of each group and which files are included. The files in each group will be merged into one code file separately.</p>

<p>In addition, <code class="highlighter-rouge">batchsize = 0</code> also forcibly disables the Batch mode, that is, if there is no unity_group grouped code files, we will still compile them separately, and will not automatically turn on automatic merging.</p>

<h4 id="batch-and-group-mixed-mode">Batch and Group mixed mode</h4>

<p>As long as we change the above <code class="highlighter-rouge">batchsize = 0</code> to a value other than 0, we can let the remaining code files continue to open the Batch mode in the grouping mode to automatically merge and compile.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_includedirs</span><span class="p">(</span><span class="s2">"src"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"c++.unity_build"</span><span class="p">,</span> <span class="p">{</span><span class="n">batchsize</span> <span class="o">=</span> <span class="mi">2</span><span class="p">})</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">,</span> <span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/foo/*.c"</span><span class="p">,</span> <span class="p">{</span><span class="n">unity_group</span> <span class="o">=</span> <span class="s2">"foo"</span><span class="p">})</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/bar/*.c"</span><span class="p">,</span> <span class="p">{</span><span class="n">unity_group</span> <span class="o">=</span> <span class="s2">"bar"</span><span class="p">})</span>
</code></pre>
</div>

<h4 id="ignore-the-specified-file">Ignore the specified file</h4>

<p>If it is in Batch mode, because it is an automatic merge operation, all files will be merged by default, but if some code files do not want to participate in the merge, then we can also ignore them through <code class="highlighter-rouge"><span class="p">{</span><span class="err">unity_ignored</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="err">true</span><span class="p">}</span></code>.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_includedirs</span><span class="p">(</span><span class="s2">"src"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"c++.unity_build"</span><span class="p">,</span> <span class="p">{</span><span class="n">batchsize</span> <span class="o">=</span> <span class="mi">2</span><span class="p">})</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">,</span> <span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/test/*.c"</span><span class="p">,</span> <span class="p">{</span><span class="n">unity_ignored</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span> <span class="o">-</span> <span class="n">ignore</span> <span class="n">these</span> <span class="n">files</span>
</code></pre>
</div>

<h4 id="unique-id">Unique ID</h4>

<p>Although the benefits of Unity Build are good, we still encounter some unexpected situations. For example, in our two code files, under the global namespace, there are global variables and functions with the same name.</p>

<p>Then, merge compilation will bring about compilation conflicts, and the compiler usually reports global variable redefinition errors.</p>

<p>In order to solve this problem, we need to make some modifications to the user code, and then cooperate with the build tool to solve it.</p>

<p>For example, our foo.cpp and bar.cpp both have global variable i.</p>

<p>foo.cpp</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="n">namespace</span> <span class="p">{</span>
    <span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="n">foo</span><span class="p">()</span>
<span class="p">{</span>
    <span class="k">return</span> <span class="n">i</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>

<p>bar.cpp</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="n">namespace</span> <span class="p">{</span>
    <span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="n">bar</span><span class="p">()</span>
<span class="p">{</span>
    <span class="k">return</span> <span class="n">i</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>

<p>Then, our merge compilation will conflict, and we can introduce a Unique ID to isolate the global anonymous space.</p>

<p>foo.cpp</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="n">namespace</span> <span class="n">MY_UNITY_ID</span> <span class="p">{</span>
    <span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="n">foo</span><span class="p">()</span>
<span class="p">{</span>
    <span class="k">return</span> <span class="n">MY_UNITY_ID</span><span class="o">::</span><span class="n">i</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>

<p>bar.cpp</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="n">namespace</span> <span class="n">MY_UNITY_ID</span> <span class="p">{</span>
    <span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="n">bar</span><span class="p">()</span>
<span class="p">{</span>
    <span class="k">return</span> <span class="n">MY_UNITY_ID</span><span class="o">::</span><span class="n">i</span><span class="p">;</span>
<span class="p">}</span>
</code></pre>
</div>

<p>Next, we also need to ensure that after the code is merged, the definitions of <code class="highlighter-rouge">MY_UNITY_ID</code> in foo and bar are completely different, and a unique ID value can be calculated according to the file name, which does not conflict with each other, which is to achieve the following merge effect:</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cp">#define MY_UNITY_ID &lt;hash(foo.cpp)&gt;
#include "foo.c"
#undef MY_UNITY_ID
#define MY_UNITY_ID &lt;hash(bar.cpp)&gt;
#include "bar.c"
#undef MY_UNITY_ID
</span></code></pre>
</div>

<p>This may seem troublesome, but the user does not need to care about these, xmake will automatically process them when merging, the user only needs to specify the name of the Unique ID, for example, the following:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_includedirs</span><span class="p">(</span><span class="s2">"src"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"c++.unity_build"</span><span class="p">,</span> <span class="p">{</span><span class="n">batchsize</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> <span class="n">uniqueid</span> <span class="o">=</span> <span class="s2">"MY_UNITY_ID"</span><span class="p">})</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">,</span> <span class="s2">"src/*.cpp"</span><span class="p">)</span>
</code></pre>
</div>

<p>Dealing with global variables, as well as global macro definitions with the same name, functions, etc., can be used in this way to avoid conflicts.</p>

<h3 id="c20-modules">C++20 Modules</h3>

<p>xmake uses <code class="highlighter-rouge">.mpp</code> as the default module extension, but also supports <code class="highlighter-rouge">.ixx</code>, <code class="highlighter-rouge">.cppm</code>, <code class="highlighter-rouge">.mxx</code> and other extensions.</p>

<p>In the early days, xmake experimentally supported C++ Modules TS, but at that time, gcc could not support it well, and the dependencies between modules were not supported either.</p>

<p>Recently, we have made a lot of improvements to xmake. We have fully supported the C++20 Modules construction support of gcc-11/clang/msvc, and can automatically analyze the dependencies between modules to maximize parallel compilation.</p>

<p>At the same time, the new version of clang/msvc has also been better handled.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">set_languages</span><span class="p">(</span><span class="s2">"c++20"</span><span class="p">)</span>
<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">,</span> <span class="s2">"src/*.mpp"</span><span class="p">)</span>
</code></pre>
</div>

<p>For more examples, see: <a href="https://github.com/xmake-io/xmake/tree/master/tests/projects/c%2B%2B/modules">C++ Modules</a></p>

<h3 id="lua54-runtime-support">Lua5.4 runtime support</h3>

<p>In the last version, we added support for the Lua5.3 runtime. In this version, we further upgraded the Lua runtime to 5.4. Compared with 5.3, the runtime performance and memory utilization have been greatly improved.</p>

<p>However, the current default runtime of xmake is still luajit, and it is expected that version 2.6.1 (that is, the next version) will officially switch to Lua5.4 as the default runtime.</p>

<p>Although the Lua runtime is switched, it is completely unaware to the user side and fully compatible with the existing project configuration, because xmake originally provides a layer of encapsulation for the exposed api.
The interfaces that have compatibility issues between Lua versions, such as setfenv, ffi, etc., are hidden internally and are not exposed to users.</p>

<h3 id="keil-mdk-tool-chain-support">Keil MDK tool chain support</h3>

<p>In this version, we also added Keil/MDK embedded compilation tool chain support, related example projects: <a href="https://github.com/xmake-io/xmake/tree/dev/tests/projects /mdk/hello">Example</a></p>

<p>xmake will automatically detect the compiler installed by Keil/MDK, related issues <a href="https://github.com/xmake-io/xmake/issues/1753">#1753</a>.</p>

<h4 id="compile-with-armcc">Compile with armcc</h4>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p cross -a cortex-m3 --toolchain=armcc -c
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<h4 id="compile-with-armclang">Compile with armclang</h4>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p cross -a cortex-m3 --toolchain=armclang -c
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<h4 id="console-program-1">Console Program</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>
    <span class="n">add_deps</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"mdk.console"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">,</span> <span class="s2">"src/*.s"</span><span class="p">)</span>
    <span class="n">add_defines</span><span class="p">(</span><span class="s2">"__EVAL"</span><span class="p">,</span> <span class="s2">"__MICROLIB"</span><span class="p">)</span>
    <span class="n">add_includedirs</span><span class="p">(</span><span class="s2">"src/lib/cmsis"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="static-library-program-1">Static library program</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"mdk.static"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/foo/*.c"</span><span class="p">)</span>
</code></pre>
</div>

<h3 id="wasi-toolchain-support">Wasi toolchain support</h3>

<p>We previously supported the emcc tool chain of the wasm platform to build the wasm program, and here, we added another Wasm tool chain with WASI enabled to replace emcc.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f -p wasm --toolchain=wasi
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<h3 id="circle-toolchain-support">Circle toolchain support</h3>

<p>We also added support for the circle compiler, which is a new C++20 compiler with some interesting compile-time meta-programming features. Those who are interested can check it out on the official website: https://www.circle -lang.org/</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f --toolchain=circle
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<h3 id="gcc-891011-specific-version-support">gcc-8/9/10/11 specific version support</h3>

<p>If the user additionally installs a specific version of the gcc tool chain such as gcc-11, gcc-10, the local gcc program may be named <code class="highlighter-rouge">/usr/bin/gcc-11</code>.</p>

<p>One way is to switch by specifying the configuration one by one through <code class="highlighter-rouge">xmake f --cc=gcc-11 --cxx=gcc-11 --ld=g++-11</code>, but it is very cumbersome.</p>

<p>Therefore, xmake also provides a faster switching method:</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> f --toolchain=gcc-11 -c
</span><span class="w">$ </span><span class="nc">xmake</span><span class="kv">
</span></code></pre>
</div>

<p>You only need to specify the version name corresponding to <code class="highlighter-rouge">gcc-11</code> to quickly switch the entire gcc tool chain.</p>

<h3 id="c1720-compiler-feature-detection">C++17/20 Compiler feature detection</h3>

<p>xmake provides the check_features auxiliary interface to detect compiler features.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">includes</span><span class="p">(</span><span class="s2">"check_features.lua"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"*.c"</span><span class="p">)</span>
    <span class="n">add_configfiles</span><span class="p">(</span><span class="s2">"config.h.in"</span><span class="p">)</span>
    <span class="n">configvar_check_features</span><span class="p">(</span><span class="s2">"HAS_CONSTEXPR"</span><span class="p">,</span> <span class="s2">"cxx_constexpr"</span><span class="p">)</span>
    <span class="n">configvar_check_features</span><span class="p">(</span><span class="s2">"HAS_CONSEXPR_AND_STATIC_ASSERT"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"cxx_constexpr"</span><span class="p">,</span> <span class="s2">"c_static_assert"</span><span class="p">},</span> <span class="p">{</span><span class="n">languages</span> <span class="err">​​</span><span class="o">=</span> <span class="s2">"c++11"</span><span class="p">})</span>
</code></pre>
</div>

<p>config.h.in</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_CONSTEXPR</span><span class="p">}</span>
<span class="err">$</span><span class="p">{</span><span class="n">define</span> <span class="n">HAS_CONSEXPR_AND_STATIC_ASSERT</span><span class="p">}</span>
</code></pre>
</div>

<p>config.h</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="cm">/* #undef HAS_CONSTEXPR */</span>
<span class="cp">#define HAS_CONSEXPR_AND_STATIC_ASSERT 1
</span></code></pre>
</div>

<p>In version 2.5.9, we added c++17 feature detection:</p>

<table>
  <thead>
    <tr>
      <th>Feature name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>cxx_aggregate_bases</td>
    </tr>
    <tr>
      <td>cxx_aligned_new</td>
    </tr>
    <tr>
      <td>cxx_capture_star_this</td>
    </tr>
    <tr>
      <td>cxx_constexpr</td>
    </tr>
    <tr>
      <td>cxx_deduction_guides</td>
    </tr>
    <tr>
      <td>cxx_enumerator_attributes</td>
    </tr>
    <tr>
      <td>cxx_fold_expressions</td>
    </tr>
    <tr>
      <td>cxx_guaranteed_copy_elision</td>
    </tr>
    <tr>
      <td>cxx_hex_float</td>
    </tr>
    <tr>
      <td>cxx_if_constexpr</td>
    </tr>
    <tr>
      <td>cxx_inheriting_constructors</td>
    </tr>
    <tr>
      <td>cxx_inline_variables</td>
    </tr>
    <tr>
      <td>cxx_namespace_attributes</td>
    </tr>
    <tr>
      <td>cxx_noexcept_function_type</td>
    </tr>
    <tr>
      <td>cxx_nontype_template_args</td>
    </tr>
    <tr>
      <td>cxx_nontype_template_parameter_auto</td>
    </tr>
    <tr>
      <td>cxx_range_based_for</td>
    </tr>
    <tr>
      <td>cxx_static_assert</td>
    </tr>
    <tr>
      <td>cxx_structured_bindings</td>
    </tr>
    <tr>
      <td>cxx_template_template_args</td>
    </tr>
    <tr>
      <td>cxx_variadic_using</td>
    </tr>
  </tbody>
</table>

<p>Also added c++20 feature detection:</p>

<table>
  <thead>
    <tr>
      <th>Feature name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>cxx_aggregate_paren_init</td>
    </tr>
    <tr>
      <td>cxx_char8_t</td>
    </tr>
    <tr>
      <td>cxx_concepts</td>
    </tr>
    <tr>
      <td>cxx_conditional_explicit</td>
    </tr>
    <tr>
      <td>cxx_consteval</td>
    </tr>
    <tr>
      <td>cxx_constexpr</td>
    </tr>
    <tr>
      <td>cxx_constexpr_dynamic_alloc</td>
    </tr>
    <tr>
      <td>cxx_constexpr_in_decltype</td>
    </tr>
    <tr>
      <td>cxx_constinit</td>
    </tr>
    <tr>
      <td>cxx_deduction_guides</td>
    </tr>
    <tr>
      <td>cxx_designated_initializers</td>
    </tr>
    <tr>
      <td>cxx_generic_lambdas</td>
    </tr>
    <tr>
      <td>cxx_impl_coroutine</td>
    </tr>
    <tr>
      <td>cxx_impl_destroying_delete</td>
    </tr>
    <tr>
      <td>cxx_impl_three_way_comparison</td>
    </tr>
    <tr>
      <td>cxx_init_captures</td>
    </tr>
    <tr>
      <td>cxx_modules</td>
    </tr>
    <tr>
      <td>cxx_nontype_template_args</td>
    </tr>
    <tr>
      <td>cxx_using_enum</td>
    </tr>
  </tbody>
</table>

<h3 id="xrepo-package-virtual-environment-management">Xrepo package virtual environment management</h3>

<h4 id="enter-the-virtual-environment">Enter the virtual environment</h4>

<p>The xrepo package management tool that comes with xmake can now well support package virtual machine environment management, similar to nixos’ nixpkgs.</p>

<p>We can customize some package configurations by adding the xmake.lua file in the current directory, and then enter the specific package virtual environment.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib 1.2.11"</span><span class="p">)</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"python 3.x"</span><span class="p">,</span> <span class="s2">"luajit"</span><span class="p">)</span>
</code></pre>
</div>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xrepo</span><span class="kv"> env shell
</span>&gt; python --version
&gt; luajit --version
</code></pre>
</div>

<p>We can also configure and load the corresponding toolchain environment in xmake.lua, for example, load the VS compilation environment.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">set_toolchains</span><span class="p">(</span><span class="s2">"msvc"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="manage-virtual-environments">Manage virtual environments</h4>

<p>We can use the following command to register the specified virtual environment configuration globally to the system for quick switching.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xrepo</span><span class="kv"> env --add /tmp/base.lua
</span></code></pre>
</div>

<p>At this time, we have saved a global virtual environment called base, and we can view it through the list command.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xrepo</span><span class="kv"> env --list
</span>/Users/ruki/.xmake/envs:
  -base
envs(1) found!
</code></pre>
</div>

<p>We can also delete it.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xrepo</span><span class="kv"> env --remove base
</span></code></pre>
</div>

<h4 id="switch-global-virtual-environment">Switch global virtual environment</h4>

<p>If we register multiple virtual environments, we can also switch them quickly.</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xrepo</span><span class="kv"> env -b base shell
</span>&gt; python --version
</code></pre>
</div>

<p>Or directly load the specified virtual environment to run specific commands</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xrepo</span><span class="kv"> env -b base python --version
</span></code></pre>
</div>

<p><code class="highlighter-rouge">xrepo env -b/--bind</code> is to bind the specified virtual environment. For more details, see: <a href="https://github.com/xmake-io/xmake/issues/1762">#1762</a></p>

<h3 id="header-only-target-type">Header Only Target Type</h3>

<p>For the target, we added the <code class="highlighter-rouge">headeronly</code> target type. For this type of target program, we will not actually compile them because it has no source files to be compiled.</p>

<p>But it contains a list of header files, which are usually used for the installation of headeronly library projects, the generation of file lists for IDE projects, and the generation of cmake/pkgconfig import files during the installation phase.</p>

<p>E.g:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.release"</span><span class="p">,</span> <span class="s2">"mode.debug"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"headeronly"</span><span class="p">)</span>
    <span class="n">add_headerfiles</span><span class="p">(</span><span class="s2">"src/foo.h"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"utils.install.cmake_importfiles"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"utils.install.pkgconfig_importfiles"</span><span class="p">)</span>
</code></pre>
</div>

<p>For more details, please see: <a href="https://github.com/xmake-io/xmake/issues/1747">#1747</a></p>

<h3 id="find-packages-from-cmake">Find packages from CMake</h3>

<p>Now cmake is the de facto standard, so the find_package provided by CMake can already find a large number of libraries and modules. We fully reuse this part of cmake’s ecology to expand xmake’s integration of packages.</p>

<p>We can use <code class="highlighter-rouge">find_package("cmake::xxx")</code> to find some packages with cmake, xmake will automatically generate a cmake script to call cmake’s find_package to find some packages and get the bread information.</p>

<p>E.g:</p>

<div class="language-console highlighter-rouge"><pre class="highlight"><code><span class="w">$ </span><span class="nc">xmake</span><span class="kv"> l find_package cmake::ZLIB
</span>{
  links = {
    "z"
  },
  includedirs = {
    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
15.sdk/usr/include"
  },
  linkdirs = {
    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.
15.sdk/usr/lib"
  }
}
<span class="w">$ </span><span class="nc">xmake</span><span class="kv"> l find_package cmake::LibXml2
</span>{
  links = {
    "xml2"
  },
  includedirs = {
    "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/libxml2"
  },
  linkdirs = {
    "/usr/lib"
  }
}
</code></pre>
</div>

<h4 id="specify-version">Specify version</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">find_package</span><span class="p">(</span><span class="s2">"cmake::OpenCV"</span><span class="p">,</span> <span class="p">{</span><span class="n">required_version</span> <span class="o">=</span> <span class="s2">"4.1.1"</span><span class="p">})</span>
</code></pre>
</div>

<h4 id="specified-components">Specified components</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">find_package</span><span class="p">(</span><span class="s2">"cmake::Boost"</span><span class="p">,</span> <span class="p">{</span><span class="n">components</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"regex"</span><span class="p">,</span> <span class="s2">"system"</span><span class="p">}})</span>
</code></pre>
</div>

<h4 id="default-switch">Default switch</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">find_package</span><span class="p">(</span><span class="s2">"cmake::Boost"</span><span class="p">,</span> <span class="p">{</span><span class="n">components</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"regex"</span><span class="p">,</span> <span class="s2">"system"</span><span class="p">},</span> <span class="n">presets</span> <span class="o">=</span> <span class="p">{</span><span class="n">Boost_USE_STATIC_LIB</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
<span class="n">set</span><span class="p">(</span><span class="n">Boost_USE_STATIC_LIB</span> <span class="n">ON</span><span class="p">)</span> <span class="o">-</span> <span class="n">will</span> <span class="n">be</span> <span class="n">used</span> <span class="k">in</span> <span class="n">FindBoost</span><span class="p">.</span><span class="n">cmake</span>
<span class="n">find_package</span><span class="p">(</span><span class="n">Boost</span> <span class="n">REQUIRED</span> <span class="n">COMPONENTS</span> <span class="n">regex</span> <span class="n">system</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="set-environment-variables">Set environment variables</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">find_package</span><span class="p">(</span><span class="s2">"cmake::OpenCV"</span><span class="p">,</span> <span class="p">{</span><span class="n">envs</span> <span class="o">=</span> <span class="p">{</span><span class="n">CMAKE_PREFIX_PATH</span> <span class="o">=</span> <span class="s2">"xxx"</span><span class="p">}})</span>
</code></pre>
</div>

<h4 id="specify-custom-findfoocmake-module-script-directory">Specify custom FindFoo.cmake module script directory</h4>

<p>mydir/cmake_modules/FindFoo.cmake</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">find_package</span><span class="p">(</span><span class="s2">"cmake::Foo"</span><span class="p">,</span> <span class="p">{</span><span class="n">moduledirs</span> <span class="o">=</span> <span class="s2">"mydir/cmake_modules"</span><span class="p">})</span>
</code></pre>
</div>

<h4 id="package-dependency-integration">Package dependency integration</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">package</span><span class="p">(</span><span class="s2">"xxx"</span><span class="p">)</span>
    <span class="n">on_fetch</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">package</span><span class="p">,</span> <span class="n">opt</span><span class="p">)</span>
         <span class="k">return</span> <span class="n">package</span><span class="p">:</span><span class="n">find_package</span><span class="p">(</span><span class="s2">"cmake::xxx"</span><span class="p">,</span> <span class="n">opt</span><span class="p">)</span>
    <span class="k">end</span><span class="p">)</span>
<span class="n">package_end</span><span class="p">()</span>

<span class="n">add_requires</span><span class="p">(</span><span class="s2">"xxx"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="package-dependency-integration-optional-component">Package dependency integration (optional component)</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">package</span><span class="p">(</span><span class="s2">"boost"</span><span class="p">)</span>
    <span class="n">add_configs</span><span class="p">(</span><span class="s2">"regex"</span><span class="p">,</span> <span class="p">{</span><span class="n">description</span> <span class="o">=</span> <span class="s2">"Enable regex."</span><span class="p">,</span> <span class="n">default</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">type</span> <span class="o">=</span> <span class="s2">"boolean"</span><span class="p">})</span>
    <span class="n">on_fetch</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">package</span><span class="p">,</span> <span class="n">opt</span><span class="p">)</span>
         <span class="n">opt</span><span class="p">.</span><span class="n">components</span> <span class="o">=</span> <span class="p">{}</span>
         <span class="k">if</span> <span class="n">package</span><span class="p">:</span><span class="n">config</span><span class="p">(</span><span class="s2">"regex"</span><span class="p">)</span> <span class="k">then</span>
             <span class="nb">table.insert</span><span class="p">(</span><span class="n">opt</span><span class="p">.</span><span class="n">components</span><span class="p">,</span> <span class="s2">"regex"</span><span class="p">)</span>
         <span class="k">end</span>
         <span class="k">return</span> <span class="n">package</span><span class="p">:</span><span class="n">find_package</span><span class="p">(</span><span class="s2">"cmake::Boost"</span><span class="p">,</span> <span class="n">opt</span><span class="p">)</span>
    <span class="k">end</span><span class="p">)</span>
<span class="n">package_end</span><span class="p">()</span>

<span class="n">add_requires</span><span class="p">(</span><span class="s2">"boost"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">regex</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<p>Related issues: <a href="https://github.com/xmake-io/xmake/issues/1632">#1632</a></p>

<h3 id="add-custom-commands-to-cmakeliststxt">Add custom commands to CMakelists.txt</h3>

<p>We have further improved the cmake generator. Now you can serialize the custom script in rule into a list of commands and generate them together to CMakelists.txt</p>

<p>However, currently only the serialization of batchcmds series scripts can be supported.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">rule</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">after_buildcmd</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">,</span> <span class="n">batchcmds</span><span class="p">,</span> <span class="n">opt</span><span class="p">)</span>
        <span class="n">batchcmds</span><span class="p">:</span><span class="n">show</span><span class="p">(</span><span class="s2">"hello xmake!"</span><span class="p">)</span>
        <span class="n">batchcmds</span><span class="p">:</span><span class="n">cp</span><span class="p">(</span><span class="s2">"xmake.lua"</span><span class="p">,</span> <span class="s2">"/tmp/"</span><span class="p">)</span>
        <span class="o">-</span> <span class="n">batchcmds</span><span class="p">:</span><span class="n">execv</span><span class="p">(</span><span class="s2">"echo"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"hello"</span><span class="p">,</span> <span class="s2">"world!"</span><span class="p">})</span>
        <span class="o">-</span> <span class="n">batchcmds</span><span class="p">:</span><span class="n">runv</span><span class="p">(</span><span class="s2">"echo"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"hello"</span><span class="p">,</span> <span class="s2">"world!"</span><span class="p">})</span>
    <span class="k">end</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
</code></pre>
</div>

<p>It will generate CMakelists.txt similar to the following</p>

<div class="highlighter-rouge"><pre class="highlight"><code># ...
add_custom_command(TARGET test
    POST_BUILD
    COMMAND echo hello xmake!
    VERBATIM
)
add_custom_command(TARGET test
    POST_BUILD
    COMMAND cp xmake.lua /tmp/
    VERBATIM
)
target_sources(test PRIVATE
    src/main.c
)
</code></pre>
</div>

<p>However, the actual effect of cmake’s <code class="highlighter-rouge">ADD_CUSTOM_COMMAND</code> PRE_BUILD differs greatly on different generators, which cannot meet our needs, so we have done a lot of processing to support it.</p>

<p>Related issues: <a href="https://github.com/xmake-io/xmake/issues/1735">#1735</a></p>

<h2 id="changelog">Changelog</h2>

<h3 id="new-features">New features</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1736">#1736</a>: Support wasi-sdk toolchain</li>
  <li>Support Lua 5.4 runtime</li>
  <li>Add gcc-8, gcc-9, gcc-10, gcc-11 toolchains</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1632">#1623</a>: Support find_package from cmake</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1747">#1747</a>: Add <code class="highlighter-rouge">set_kind("headeronly")</code> for target to install files for headeronly library</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1019">#1019</a>: Support Unity build</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1438">#1438</a>: Support code amalgamation, <code class="highlighter-rouge">xmake l cli.amalgamate</code></li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1756">#1765</a>: Support nim language</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1762">#1762</a>: Manage and switch the given package envs for <code class="highlighter-rouge">xrepo env</code></li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1767">#1767</a>: Support Circle compiler</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1753">#1753</a>: Support armcc/armclang toolchains for Keil/MDK</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1774">#1774</a>: Add table.contains api</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1735">#1735</a>: Add custom command in cmake generator</li>
</ul>

<h3 id="changes">Changes</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1528">#1528</a>: Check c++17/20 features</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1729">#1729</a>: Improve C++20 modules for clang/gcc/msvc, support inter-module dependency compilation and parallel optimization</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1779">#1779</a>: Remove builtin <code class="highlighter-rouge">-Gd</code> for ml.exe/x86</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1781">#1781</a>: Improve get.sh installation script to support nixos</li>
</ul>


        </article>
        <hr>

        <!-- baidu ads -->
        

        
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="chinese">中文</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
        
            </ul>
        

        
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">Similar Posts</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/2021/12/17/xmake-update-v2.6.2/">Xmake v2.6.2 released, Support building Linux kernel driver module
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 released, Switch to Lua5.4 runtime, Support Rust and C++ mixed compilation
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 is released, Support Pascal/Swig program and Lua53 runtime
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 released, Use lockfile to freeze package dependencies and Vala/Metal language support
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/07/26/xmake-update-v2.5.6/">xmake v2.5.6 released, Improve compatibility of pre-compiled binary package
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        <p><strong>Prev Post</strong> <a href="/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 is released, Support Pascal/Swig program and Lua53 runtime</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>Next Post</strong> <a href="/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 released, Switch to Lua5.4 runtime, Support Rust and C++ mixed compilation</a></p>
        
    </div>
</div>


        <h2 id="comments">Comments</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,      
  language: 'en',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">


            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    Content
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#chinese">中文</a></li>
                    <li><a href="#similar_posts">Similar Posts</a></li>
                    <li><a href="#comments">Comments</a></li>
                </ul>
            </div>

            <!-- baidu ads -->
            

            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    Links
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

            <!-- chitika ads -->
            
        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
